package com.cn.yunhe.rentcars.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.cn.yunhe.rentcars.model.Account;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 单月收支明细科目
 * @author 赵志学
 *
 */
@RestController
public class FinanceMonthController {
	
	/**
	 * 跳转到单月收支科目页面
	 * return 页面地址
	 */
	@RequestMapping(value="/financeMonth",method=RequestMethod.GET)
	public ModelAndView financeMonth(){
		//收入科目 订单信息。
		String projectCar = "租车实收";
		double orderCount = 5;//单月收入次数。从数据库读取当月订单总数，
		double orderPriceAll = 7777;//单月收入总和。  计算所有订单金额总和。
        
        //支出科目：
       // 车辆保险   车辆保养   车辆年检   车辆维修 车主应提  押金退还
        //insurance  maintain   yearcheck    repair ownerMoney returnCash
        String insurance = "车辆保险";// 车辆保险 
        String maintain = "车辆保养";//  车辆保养      
        String yearcheck = "车辆年检" ;// 车辆年检
        String repair = "车辆维修" ;//车辆维修
        String ownerMoney = "车主应提";//车主应提 
        String returnCash = "押金退还";//押金退还
        
        Map<String,Object> rsMap = new HashMap<String,Object>();	     
	      rsMap.put("orderCount", orderCount);
	      rsMap.put("orderPriceAll", orderPriceAll);
	      rsMap.put("projectCar", projectCar);
	      rsMap.put("insurance", insurance);
	      rsMap.put("maintain",maintain );
	      rsMap.put("yearcheck", yearcheck);
	      rsMap.put("repair", repair);
	      rsMap.put("ownerMoney",ownerMoney );
	      rsMap.put("returnCash", returnCash);
		return new ModelAndView("finance-month",rsMap);
	}
	/**
	 * 跳转到店铺单月收支明细。
	 * @return
	 */	
	@RequestMapping(value="/getFinanceMonth",method=RequestMethod.POST)
	public Map<String,Object> getFinanceMonth(@RequestParam int start,@RequestParam int length,@RequestParam int draw,@RequestParam String etrentdept,@RequestParam String startTime,@RequestParam String endTime ){
		System.out.println("进入单月明细");
		//etrentdept,@RequestParam String startTime,@RequestParam String endTime
		Map<String,String> map = new HashMap<String,String>();
		map.put("etrentdept", etrentdept);		
		map.put("startTime", startTime);
		map.put("endTime",endTime);
		//PageHelper.startPage(pageNum,pageSize);
		//System.out.println("分页信息初始化完毕，准备进入数据库操作");
		//List<Account> accountList = accountMapper.getAccounts(username);
		//List<Account> accountList = (accountMapper.findAccounts(map));
		/*for(Account a : accountList){
			System.out.println("时间："+a.getAddtime()+" 名字:"+a.getUsername());
		}
		*/
		//PageInfo<Account> page = new PageInfo<Account>(accountList);
		String orderCount = "5";//单月收入次数。
        String orderPriceAll = "7777";//单月收入总和。
        String projectCar = "租车实收";
		 Map<String,Object> rsMap = new HashMap<String,Object>();
	      rsMap.put("draw",draw);
	      rsMap.put("data", "projectCar");
	     
	     // rsMap.put("data", page.getList());	      
	      rsMap.put("recordsTotal", 10);
	     rsMap.put("recordsFiltered", 10);
	   return rsMap;
	}
}
